package tree;

import javax.swing.tree.DefaultTreeModel;

//项目树的model对象
public class ProjectTreeModel extends DefaultTreeModel {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public ProjectTreeModel(ProjectTreeNode arg0){
		//设置根结点
		super(arg0);
	}
	
	public void reload(ProjectTreeNode node, TreeCreator creator){
		//获取node的父节点
		ProjectTreeNode parent = (ProjectTreeNode)node.getParent();
		//父节点为null，不需要reload
		if(parent == null){
			return;
		}
		//获取node在父节点的索引
		int index = parent.getIndex(node);
		//将node在父节点中删除
		parent.remove(index);
		//获取新的节点
		node = creator.createNode(node.getFile());
		//添加到父节点中
		parent.insert(node, index);
		super.reload(node);
	}
}
